package org.deltaset.secured.visit.menu;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.ManagedBean;
import javax.inject.Inject;
import org.deltaset.desktop.MenuGroup;
import org.deltaset.desktop.MenuItem;
import org.deltaset.secured.menu.MenuRegistry;

/**
 *
 * @author dmakariev
 */
@ManagedBean
public class LibraryMenu {

    private final static String ENTITY_SRC = "/record/meta-entity.xhtml";
    private final MenuRegistry menuRegistry;

    @Inject
    public LibraryMenu(MenuRegistry menuRegistry) {
        this.menuRegistry = menuRegistry;
        this.menuRegistry.getTopMenu().get(0).getMenuGroups().addAll(initMiniHome());
    }

    private List<MenuGroup> initMiniHome() {
        final List<MenuGroup> menuGroups = new ArrayList<MenuGroup>();
        menuGroups.add(MenuRegistry.autoObjects("Visit", "org.deltaset.secured.visit"));
        menuGroups.add(MenuRegistry.autoObjects("Uploaded Files", "org.deltaset.secured.upload"));
        menuGroups.add(MenuRegistry.autoObjects("Collection Examples", "org.deltaset.secured.example"));
        menuGroups.add(fileUpload());
//        menuGroups.add(new MenuGroup("Record").add(Person.class, ENTITY_SRC).
//                add(Animal.class, ENTITY_SRC));

        return menuGroups;
    }

    private MenuGroup fileUpload() {
        final MenuItem fileUploadItem = new MenuItem("File upload", "/fileupload.xhtml", "file-upload");
        final MenuItem dashboardItem = new MenuItem("Dashboard", "/dashboard.xhtml", "dashboardItem");
        final MenuItem scheduleItem = new MenuItem("schedule", "/schedule.xhtml", "scheduleItem");
        final MenuItem collectorItem = new MenuItem("collector", "/collector.xhtml", "collector");
        final MenuItem themeItem = new MenuItem("themeswitcher", "/themeswitcher.xhtml", "themeswitcher");
        final MenuItem dataTableItem = new MenuItem("dataTable", "/dataTable.xhtml", "dataTable");
        final MenuItem gmapItem = new MenuItem("gmap-add-marker", "/gmap-add-marker.xhtml", "gmap-add-marker");
        final MenuItem fileUploadDndItem = new MenuItem("fileUploadDnd", "/fileUploadDnd.xhtml", "fileUploadDnd");





        final MenuGroup simple = new MenuGroup("Files", "files-group");
        simple.add(fileUploadItem);
        simple.add(dashboardItem);
        simple.add(scheduleItem);
        simple.add(collectorItem);
        simple.add(themeItem);
        simple.add(dataTableItem);
        simple.add(gmapItem);
        simple.add(fileUploadDndItem);
        return simple;
    }
    //private List<MenuGroup> initMiniHome() {
    //    final List<MenuGroup> menuGroups = new ArrayList<MenuGroup>();
    //    menuGroups.add(new MenuGroup("visit").add(Person.class, ENTITY_SRC).
    //            add(Animal.class, ENTITY_SRC));
    //    return menuGroups;
    //}
}
